<!DOCTYPE html>
<html lang="en">
{include file="sunfc/public/headfile" /}
<body>

<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12" style="min-width: 100%;width: auto;">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">爱心司机列表</li>
                            <!--<li onclick="go('pm_add')">新增项目经理</li>-->
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">

                            <div class="layui-tab-item layui-show">

                                <div>
                                    <div class="layui-btn-group">
                                        <button class="layui-btn" onclick="setStatus(0);" >冻结</button>
                                        <button class="layui-btn" onclick="setStatus(1);" >启用</button>
                                        <button class="layui-btn" onclick="setStatus(-1);" >拒绝</button>
                                        <button class="layui-btn" onclick="setStatus(2);" >通过</button>
                                    </div>
                                    <div class="layui-inline" style="float: right">
                                        <form class="layui-form" action="">
                                            <div class="layui-form-item" style="margin-bottom: 0px">

                                                <div class="layui-inline" style="margin-right: 0px">

                                                    <div class="layui-input-inline" style="width: 200px;">
                                                        <input type="text" name="tel" autocomplete="off"
                                                               placeholder="姓名|昵称|手机号"
                                                               class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-inline" style="margin-right: 0px">
                                                    <div class="layui-btn-group layui-inline" style="margin: 0px">
                                                        <!--此重置 仅仅是个跳转链接-->
                                                        <button  onclick="go('index')" class="layui-btn layui-btn-primary">重置</button>
                                                        <button class="layui-btn layui-btn-normal" lay-submit
                                                                lay-filter="formDemo"><i class="layui-icon">&#xe615;</i>查找
                                                        </button>
                                                    </div>
                                                </div>

                                            </div>
                                        </form>
                                    </div>
                                </div>

                                <div class="layadmin-trailer ">

                                    <table class="layui-table" lay-skin="line">

                                        <thead>
                                        <tr>
                                            <th></th>
                                            <th>#ID</th>
                                            <th>昵称</th>
                                            <th>头像</th>
                                            <th>姓名</th>
                                            <th>手机号码</th>
                                            <th>创建时间</th>
                                            <!--<th>更新时间</th>-->
                                            <th>认证状态</th>
                                            <th>状态</th>
                                            <th></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(item,index) in items" :data_id="item.uid">
                                            <td style="width: 20px;text-align: center">
                                                <input type="checkbox" class="vue_index" name="uid" :value="item.uid"
                                                       style="zoom: 150%">
                                            </td>
                                            <td>{{item.uid}}</td>
                                            <td>{{item.nickname}}</td>
                                            <td><img :src="item.headimgurl" class="layui-circle2" style="width: 50px;height: 50px"></td>
                                            <td>{{item.realname}}</td>
                                            <td>{{item.tel}}</td>
                                            <td>{{item.create_time}}</td>
                                            <!--<td>{{item.update_time}}</td>-->
                                            <td>
                                                <span v-if="item.auth_status == -1">未通过</span>
                                                <span v-if="item.auth_status == 1">认证中</span>
                                                <span v-if="item.auth_status == 2">已通过</span>
                                            </td>
                                            <td>
                                                <span v-if="item.status==1">正常</span>
                                                <span v-if="item.status==0">冻结</span>
                                            </td>
                                            <td>

                                                <div class="layui-btn-group">
                                                    <button class="layui-btn layui-btn-sm layui-btn-primary"
                                                            :data_id="item.uid" :data_index="index" onclick="look(this)">详情
                                                    </button>
                                                    <!--<button class="layui-btn layui-btn-sm layui-btn-primary"-->
                                                    <!--:data_id="item.id" :data_index="index">操作2-->
                                                    <!--</button>-->
                                                </div>

                                            </td>
                                        </tr>

                                        </tbody>
                                    </table>


                                </div>
                                <div id="demo7"></div>

                            </div>


                        </div>
                    </div>


                </div>


            </div>

        </div>


    </div>
</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            curr: 1,//当前页
            limit: 10,//当前页
            items: []
        }
    });

    function init() {
        layer.ready(function () {
            layer.load(2);
            $.get('/admin/love.activity/index', {page: app.curr, limit: app.limit},
                function (res) {
                    layer.closeAll();
                    app.items = res.data;
                }
            );
        });

    }

    layui.use('table', function () {
        var table = layui.table;
    });
    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        //完整功能
        laypage.render({
            elem: 'demo7'
            , count: "{$count}"
            , limits: [10, 20]
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            , jump: function (obj) {
                console.log(obj)
                app.curr = obj.curr;
                app.limit = obj.limit;
                init();

            }
        });

    });
    //查看司机详情弹框
    function look(that) {

        var data_id = $(that).attr('data_id');
        layer.open({

            type: 2,
            title: '查看司机详情',
            shadeClose: true,
            shade: 0.01,
            area: ['50%', '90%'],
            content: "{:url('look')}?id=" + data_id //iframe的url

        });


    }
    //获取下标
    function getCheckBox() {
        var check = [];
        $.each($('input[type=checkbox]:checked.vue_index'), function () {
            check.push($(this).val());
        });
        return check;
    };
    // 冻结或启用
    function setStatus(status) {

        var ids = getCheckBox();
        // alert(ids);
        if (ids.length > 0) {

            var index = layer.confirm('确认继续执行？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                if((status==-1)||(status==2)){
                    //审核
                    $.post('{:url("/admin/love.activity/set_status2")}', {ids: ids,status:status}, function (res) {
                        if (res.code == 1) {
                            //alert('666');
                            layer.msg(res.msg, {icon: 1})
                            $("input:checkbox").removeAttr("checked");
                            init();
                        }
                        layer.close(index);

                    });

                }else{
                    // 冻结或启用
                    $.post('{:url("/admin/love.activity/set_status")}', {ids: ids,status:status}, function (res) {
                        if (res.code == 1) {
                            //alert('666');
                            layer.msg(res.msg, {icon: 1})
                            $("input:checkbox").removeAttr("checked");
                            init();
                        }
                        layer.close(index);

                    });

                }

            }, function () {
                layer.close(index);
            });
        }


    }
    //按需引入layui的form模块
    layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            // layer.msg(JSON.stringify(data.field));
            if ( !data.field.tel) {
                return false;
            }
            layer.load(2);
            $.get('/admin/love.activity/cases_search_index', data.field,
                function (res) {
                    //alert(res.msg);
                    layui.use(['laypage'], function () {
                        var laypage = layui.laypage;
                        //完整功能
                        laypage.render({
                            elem: 'demo7',
                            count: res.total,
                            limits: [10, 20],
                            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
                            jump: function (obj) {
                                console.log(obj)
                                app.curr = obj.curr;
                                app.limit = obj.limit;
                                layer.load(2);
                                $.get('/admin/love.activity/cases_search_index', {
                                        page: app.curr,
                                        limit: app.limit,
                                        user_id: data.field.user_id,
                                        tel: data.field.tel
                                    },
                                    function (res) {
                                        layer.closeAll();
                                        $('.layui-form')[0].reset();
                                        app.items = res.data;

                                    }
                                );
                            }
                        });
                    });
                }
            );
            return false;
        });
    });

</script>
</body>
</html>